//
//  UserUtil.m
//  deerkids
//
//  Created by 王昭的Mac Air on 2017/8/28.
//  Copyright © 2017年 wangzhao. All rights reserved.
//

#import "UserUtil.h"
#import <UMPush/UMessage.h>

@implementation UserUtil


#define UserPath  [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"user.archive"]
//#define UserPath  [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserdomainMask,YES) lastObject] stringByAppendingPathComponent:@"user.archive"]

//账户信息存储
+ (BOOL)saveUser:(User *)user
{
    [UMessage addAlias:convertToString(user.user_id) type:kUMessageAliasTypeBaidu response:^(id  _Nullable responseObject, NSError * _Nullable error) {
        
    }];
    
    return [NSKeyedArchiver archiveRootObject:user toFile:UserPath];
}

//账户信息获取
+ (User *)getUser
{
    return [NSKeyedUnarchiver unarchiveObjectWithFile:UserPath];
}

//账户信息删除
+ (BOOL)deleteUser
{
    return [[NSFileManager defaultManager] removeItemAtPath:UserPath error:nil];
}


@end
